package com.hao.tool.util.component.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;

/**
 * 处理controller异常
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger logger = LoggerFactory
            .getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(Exception.class)
    public ModelAndView exception404(HttpServletResponse response, Exception exception) {

        logger.debug("Exception:", exception);
        ModelAndView mv = new ModelAndView("common/4042");
        mv.addObject("message", exception.getMessage());
        return mv;
    }


}
